package il.technion.cs236369.webserver;

import il.technion.cs236369.webserver.typeHandlers.TypeHandler;

import java.util.Properties;

/**
 * This class is used to keep a type-handler parsed from the config.xml
 * file in the Map of the ConfigParams class.
 * @author Yuval and Eddie
 *
 */
public class ServerHandler {
	private String className;
	private Class<? extends TypeHandler> handlerClass;
	private Properties properties;

	public ServerHandler(String className) {
		this.className = className;
		handlerClass = null;
		properties = new Properties();
	}
	
	@SuppressWarnings("unchecked")
	public Class<? extends TypeHandler> getHandlerClass() throws ClassNotFoundException {
		if (handlerClass == null) {
			handlerClass = (Class<? extends TypeHandler>) Class.forName(className);
		}
		return handlerClass;
	}

	public void addParameter (String paramName, String paramValue) {
		properties.put(paramName, paramValue);
	}
	
	public Properties getProperties() {
		return properties;
	}

}
